{$CLEO .qa}
{$USE CLEO+}
{$USE newOpcodes}
{$USE ini}

0000: NOP

script_name "DropQA"

// By ArtemQa146

const
    Obj = 19@
    Model_Id = 6@
    Weapon_Render = 7@
    Heavy = 8@
    Mode = 31@
    Key_1 = 30@
    Key_2 = 29@
    Anim_Speed = 28@
    Anim_Speed_H = 27@
    find = 26@
    Ammo_left = 25@
    Ped_bone = 24@
    Damager_1 = 23@
    Type_1 = 22@
    Bone_1 = 21@
    Intensity_1 = 20@
end

0085: Mode = 1@ // (int)

            if
                056D:   actor 0@ defined
            then
                0470: 1@ = actor 0@ current_weapon
                041A: Ammo_left = 0@ pedweapon 1@ ammo

                0781: get_weapon_with_ID 1@ model_to Model_Id
                model.Load(Model_Id)
                038B: load_requested_models

                0555: remove_weapon 1@ from_actor 0@

                if
                    Mode == 1
                then
                
                    04A5: get_dead_actor_pickup_coords 0@ store_to 3@ 4@ 5@
                    04C4: store_coords_to 3@ 4@ 2@ from_actor 0@ with_offset 1.5 0.6 0.0
                    0213: 1@ = create_pickup Model_Id type 4 at 3@ 4@ 5@

                else
                
                    10@ = 0.3
                    11@ = 0.3
                    04C4: store_coords_to 3@ 4@ 5@ from_actor 0@ with_offset 10@ 11@ 0.1
                    10@ += 0.07
                    11@ += 0.07
                    0172: 1@ = actor 0@ Z_angle
                    04C4: store_coords_to 20@ 21@ 22@ from_actor 0@ with_offset 10@ 11@ 0.05
                    0E01: create_object_no_save Model_Id at 3@ 4@ 5@ offset 0 ground 0 to Obj
                    0453: set_object Obj XY_rotation 270.0 0.0 angle 1@
                    05A1: set_object Obj rotation_velocity_about_an_axis 5.0 5.0 0.0 through_center_of_body
                    0815: put_object Obj at 20@ 21@ 22@  and_keep_rotation
                    timera = 0
                    
                    0209: Ammo_left = random_int_in_ranges 15 30
                    gosub @SetAmmo

                    repeat
                    wait 0
                    0400: store_coords_to 1@ 2@ 3@ from_object Obj with_offset 0.0 0.0 0.0
                    02CE: 1@ = ground_z_at 1@ 2@ 3@
                    0063: 3@ -= 1@  // (float)
                        if
                            3@ <= 0.2
                        then
                            0176: 1@ = object Obj Z_angle
                            0453: set_object Obj XY_rotation 270.0 0.0 angle 1@
                            0382: set_object Obj collision_detection 0
                            0400: store_coords_to 1@ 2@ 3@ from_object Obj with_offset 0.0 0.0 0.0
                            02CE: 3@ = ground_z_at 1@ 2@ 3@
                            3@ += 0.06
                            01BC: put_object Obj at 1@ 2@ 3@
                            break
                        end
                    until timera > 2000
                    01C4: remove_references_to_object Obj // This object will now disappear when the player looks away
                end
                
                model.Destroy(Model_Id)
            end
            
0A93: terminate_this_custom_script


:SetAmmo
0A98: 1@ = Obj objstruct
0E28: write_struct 1@ offset 0x11 size 2 value Ammo_left //0xBC4 = [word] Free Slot 1
0E28: write_struct 1@ offset 0x13 size 1 value 1 //0xBC6 = [byte] Free Slot 2
return

            